import java.util.Scanner;

/**
 * @author gao
 * @date 2025/10/4 20:50
 */

public class Solution {
    public boolean carPooling(int[][] trips, int capacity) {
        // 创建差分数组
        int[] diff = new int[1001];

        // 处理每个行程
        for (int[] trip : trips) {
            int numPassengers = trip[0];
            int fromLocation = trip[1];
            int toLocation = trip[2];

            // 上车，增加乘客
            diff[fromLocation] += numPassengers;
            // 下车，减少乘客
            diff[toLocation] -= numPassengers;
        }

        // 计算前缀和，检查是否超载
        int curPassengers = 0;
        for (int i = 0; i < diff.length; i++) {
            curPassengers += diff[i];
            if (curPassengers > capacity) {
                return false;
            }
        }

        return true;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int n = in.nextInt();
            int[][] trips = new int[n][3];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < 3; j++) {
                    trips[i][j] = in.nextInt();
                }
            }
            int capacity = in.nextInt();
            Solution solution = new Solution();
            System.out.println(solution.carPooling(trips, capacity));
        }
    }
}